# 122. 买卖股票的最佳时机 II
# 使用动态规划的方式
def maxProfit(prices):
    """
    :type prices: List[int]
    :rtype: int
    """
    dp = [0 for _ in range(len(prices) + 1)]
    for index in range(2, len(prices) + 1):
        dp[index] = dp[index - 1] + max(prices[index - 1] - prices[index - 2], 0)
    return dp[len(prices)]


prices_1 = [7, 1, 5, 3, 6, 4]
result = maxProfit(prices_1)
print(f"result:{result}")
